home *** CD-ROM | disk | FTP | other *** search
/ The 640 MEG Shareware Studio 2 / The 640 Meg Shareware Studio CD-ROM Volume II (Data Express)(1993).ISO / prog / lvswin.zip / DEMO.CPP next >
Text File  |  1991-11-06  |  26KB  |  878 lines

  1. /*
  2.  *            LVS Windows
  3.  *      The Window Class System
  4.  *
  5.  *        Copyright 1991 (c), Lake View Software
  6.  *                            4321 Harborough Rd.
  7.  *                            Columbus, OH 43220
  8.  *        All rights reserved.
  9.  *
  10.  * DEMO.CPP
  11.  */
  12.  
  13. #include <stdlib.h>
  14. #include <dos.h>
  15. #include <time.h>
  16. #ifdef __TURBOC__
  17.     #include <alloc.h>
  18. #else
  19.     /*
  20.      * Zortech
  21.      */
  22.     #define gettime         dos_gettime
  23.     #define time            dos_time_t
  24.     #define ti_sec          second
  25.     #define ti_hour         hour
  26.     #define ti_min          minute
  27.     #define random(num)     (int)(((long)rand()*(num))/(0x7FFFU + 1))
  28.     #define delay           usleep
  29.     #define coreleft        farcoreleft
  30. #endif
  31. #include <conio.h>
  32. #include <ctype.h>
  33. #include <stdio.h>
  34. #include "Win_Prn.hpp"        // print class
  35. #include "WinTools.hpp"     // Add on tools 
  36. #include "WinMenu.hpp"      // Menu class header file
  37. #include "WinPick.hpp"      // Pick-List class header file
  38. #include "WinMouse.Hpp"     // Mouse driver
  39.  
  40. /*
  41.  * Declaring a single object of this class will save the current
  42.  * screen contents and mode to be restored when the program exits.
  43.  * Note:  - The destructor of this class calls Win_close_all ();
  44.  *        - This needs to be the first declared object so it can
  45.  *          capture the screen.
  46.  *        - This cleans up the loaded VGA fonts and blink state on 
  47.  *          program exit
  48.  */
  49. ScreenState win_state;
  50.  
  51. /*
  52.  * Some global window objects
  53.  */
  54. WinObj win1,win2;   // Some global window objects, These will be the random windows
  55. WinObj Scroll;        // Scrolling text demo
  56. WinObj Scroll2;
  57.  
  58. /*
  59.  * Declare internal functions
  60.  */
  61. int  v_salary(void *num);
  62. int  v_age(void *num);
  63. void rand_open (WinObj &w), show_time (), move_windows (struct time t),
  64.      data_entry (), paradox_entry (), moving_windows (),
  65.      random_windows (), scroll_demo (), scroll_window (),
  66.      menu_demo (), menu_demo2 (), pick_demo (), help (),
  67.      logo ();
  68.  
  69. int VGA = 0;            // has vga flag
  70. int Use_VGA = 1;        // try to use vga graphics/colors by default
  71.  
  72. void main (int argc, char **argv)
  73. {
  74.     int arg=0;
  75.  
  76.     int mouse_mode = M_FULL;              // Default mouse mode 
  77.  
  78.     while (++arg < argc) 
  79.         {                    // Parse the command line
  80.         if (argv[arg][0] == '-' || argv[arg][0] == '/') 
  81.             {
  82.             switch (toupper (argv[arg][1])) 
  83.                 {
  84.                 case 'B': 
  85.                     Win_bios(W_ON);     // Turn on use of bios writes
  86.                     break;
  87.  
  88.                 case 'S': 
  89.                     Win_snow(W_ON);     // Turn on use of snow suppression
  90.                     break;
  91.  
  92.                 case 'M': 
  93.                     switch (toupper (argv[arg][2]))
  94.                         {
  95.                         case 'N':                 // Mouse off
  96.                             mouse_mode = M_NONE;
  97.                             break;
  98.  
  99.                         case 'S':                 // Mouse full support
  100.                             mouse_mode = M_SIMPLE;
  101.                             break;
  102.  
  103.                         default:
  104.                             Win_mono(W_ON);     // Force black & white only
  105.                             break;
  106.                         }
  107.                         break;
  108.                 case '5': 
  109.                     VGA_setlines (50);
  110.                     break;
  111.                 case '2':
  112.                     VGA_setlines (28);
  113.                     break;
  114.                 case 'V':
  115.                     Use_VGA = 0;
  116.                     break;
  117.                 }
  118.             }
  119.         }
  120.  
  121.     srand (1);
  122.  
  123.     // Turn clock on
  124.     Win_setbkloop (show_time);          // Set background keyboard loop
  125.                                         // This will run the clock and move win1
  126.                                         // & win2
  127.  
  128.     Win_setonkey (F1,help);             // Set F1 to function help
  129.     Win_setonkey (F10, Win_Calculator);
  130.     Win_setonkey (F5, Win_Calendar);
  131.  
  132.     /*
  133.      * Display the logo
  134.      */
  135.     logo ();
  136.  
  137.     /*
  138.      * Open the main menu
  139.      */
  140.     WinMenu m;                                      // create Main menu object
  141.  
  142.     int bkground_color = _RED;
  143.     if (VGA)
  144.         bkground_color = _LBLUE;
  145.  
  146.     m.open (4, 26, 15, 52, W_DOUSIN, bkground_color|WHITE, 
  147.             bkground_color|BLACK);             // Open the window
  148.     m.shadow ();                               // make a shadow for the window
  149.     m.set_keyattr (bkground_color|YELLOW);     // change the hot key attribute
  150.  
  151.     bkground_color = _LGREY;
  152.     if (VGA)
  153.         bkground_color = _WHITE;
  154.     m.title (" Demo Menu ");                 // Give the window a title
  155.  
  156.     /*
  157.      * Define the menu selections
  158.      */
  159.     m.prompt (1, 2, 1, " 1. Data entry       ", "", '1');
  160.     m.prompt (2, 2, 2, " 2. Moving windows   ", "", '2');
  161.     m.prompt (3, 2, 3, " 3. Random windows   ", "", '3');
  162.     m.prompt (4, 2, 4, " 4. Lotus style menu ", "", '4');
  163.     m.prompt (5, 2, 5, " 5. Pick-List demo   ", "", '5');
  164.     m.prompt (6, 2, 6, " 6. Scrolling demo   ", "", '6');
  165.     #ifdef __TURBOC__
  166.         m.prompt (7, 2, 7, " 7. Paradox entry    ", "", '7');
  167.     #else
  168.         m.printf (7, 2, " 7. Paradox entry    ");
  169.     #endif
  170.     m.prompt (8, 2, 0, " 0. Quit             ", "", '0');
  171.  
  172.     /*
  173.      * Init the mouse driver
  174.      */
  175.     Win_mouse_mode (mouse_mode);
  176.  
  177.     
  178.     int choice = 1;                         // start with menu selection ret_val = 1
  179.  
  180.     while (choice != 0) 
  181.         {                   // loop till Quit is selected
  182.  
  183.         choice = m.read (choice);           // get menu selection from user
  184.  
  185.         switch (choice) 
  186.             {
  187.             case 1: 
  188.                 data_entry ();
  189.                 break;
  190.             case 2: 
  191.                 moving_windows ();
  192.                 break;
  193.             case 3: 
  194.                 random_windows ();
  195.                 break;
  196.             case 4: 
  197.                 m.hide ();                  // hide the main menu
  198.                 menu_demo ();
  199.                 break;
  200.             case 5: 
  201.                 pick_demo ();
  202.                 break;
  203.             case 6: 
  204.                 scroll_demo ();
  205.                 break;
  206.             case 7:
  207.                 paradox_entry ();
  208.                 break;
  209.             }
  210.         }
  211.  
  212.     // all windows will close automatically with there destructors
  213. }
  214.  
  215. //*********************Pick-List Demo************************
  216.  
  217. static char *list[] = { "January",   "February",
  218.                         "March",     "April",
  219.                         "May",       "June",
  220.                         "July",      "August",
  221.                         "September", "October",
  222.                         "November",  "December",  0 };
  223.  
  224. void pick_demo()
  225. {
  226.     WinPick pl;
  227.  
  228.     int bk = _BLUE;
  229.     if (VGA)
  230.         bk = _DGREY;
  231.  
  232.     pl.open (3, 33, 9, 45, W_DOUSIN, bk|WHITE, bk|GREEN);  // open pick window
  233.     pl.shadow();
  234.     pl.title ("Pick-List");
  235.     pl.prompt (list);           // assign a list
  236.     int choice = pl.read();     // get user selection, closes window when finished
  237.  
  238.     // Display the results of the pick.
  239.     if (choice != W_ESCAPE) 
  240.         {
  241.         WinObj w;
  242.         w.open (6, 23, 11, 53, W_DOUSIN, bk|GREEN, bk|WHITE);
  243.         w.title (" Answer ");
  244.         w.shadow ();
  245.         w.printf (1, 1, "You picked ");
  246.         w.set_attr (bk|YELLOW);
  247.         w.printf ("%s.", list[choice]);
  248.         w.set_attr (bk|LGREY);
  249.         w.printf (3, 1, "Press any key to continue.");
  250.         w.get_key ();
  251.         }
  252. }
  253.  
  254. //**********************Menu Demo****************************
  255. // First level of a lotus style menu
  256. void menu_demo ()
  257. {
  258.     WinMenu m;                                      // Create a menu object
  259.     m.open (1, 0, 1, 79, W_NOBORDER, _BLUE|WHITE);  // init the window
  260.     m.message_line (2);                             // Set message line to 2
  261.     m.set_keyattr (_BLUE|YELLOW);                   // hot key attribute
  262.     m.set_barattr (_RED|WHITE);                     // make bar white on red
  263.  
  264.     // Declare some menu selections
  265.     m.prompt (0,  0, 1, " Worksheet ", "Global, Column, Status, Delete", 'W');
  266.     m.prompt (0, 12, 2, " Range ", "Format, Label, Erase, Name, Justify, Prot", 'R');
  267.     m.prompt (0, 20, 3, " Copy ",  "Copy a cell or range of cells", 'C');
  268.     m.prompt (0, 27, 4, " mOve ",  "Move a cell or range of cells", 'O');
  269.     m.prompt (0, 34, 5, " File ",  "Retrieve, Save, Combine, Xtract...", 'F');
  270.     m.prompt (0, 41, 6, " Print ", "Print a worksheet to a printer or file", 'P');
  271.     m.prompt (0, 49, 0, " Quit ",  "Quit the menu demo", 'Q');
  272.                     
  273.     int choice=1;
  274.     while (choice != 0) 
  275.         {
  276.         choice = m.read(choice);        // Get a menu selection
  277.         if (choice == W_ESCAPE)
  278.             break;
  279.         switch (choice) 
  280.             {
  281.             case 1:
  282.                 menu_demo2();           // Goto next menu level
  283.                 break;
  284.             case 2:
  285.                 break;
  286.             }
  287.         }
  288.     // Menu object will destruct and close automatically.
  289. }
  290.  
  291. void menu_demo2()       // Second level of a lotus style menu
  292. {
  293.     WinMenu m;
  294.     m.open (1, 0, 1, 79, W_NOBORDER, _BLUE|WHITE);
  295.     m.message_line (2);                             // Set message line to 1
  296.     m.set_keyattr (_BLUE|YELLOW);                   // make hot key yellow
  297.     m.set_barattr (_RED|WHITE);                     // make bar white on red
  298.  
  299.     m.prompt (0,  0, 1, " Global ", "Global functions", 'G');
  300.     m.prompt (0,  9, 2, " Column ", "Delete, Insert", 'C');
  301.     m.prompt (0, 18, 3, " Status ", "Display worksheet status", 'S');
  302.     m.prompt (0, 27, 4, " Delete ", "Delete the entire worksheet", 'D');
  303.     m.prompt (0, 36, 5, " sYstem ", "Shell to DOS", 'Y');
  304.     m.prompt (0, 45, 0, " Quit ", "Quit to the main menu", 'Q');
  305.     int choice=1;
  306.     while (choice != 0) 
  307.         {
  308.         choice = m.read(choice);
  309.         if (choice == W_ESCAPE)
  310.             break;
  311.  
  312.         switch (choice) 
  313.             {
  314.             case 1:
  315.                 break;
  316.             case 2:
  317.                 break;
  318.             case 5:
  319.                 Win_clrscr ();
  320.                 puts ("Type 'EXIT' to return to demo.\n\n\n");
  321.                 system ("");
  322.                 m.update_all ();
  323.                 break;
  324.             }
  325.         }
  326. }
  327.  
  328. //*************************Moving windows Demo*************************
  329. // Open the moving windows
  330. void moving_windows()
  331. {
  332.     // Windows will open or close with each call
  333.     if (!win1.is_open()) 
  334.         {
  335.         win1.open (1, 1, 10, 25, W_DOUBLE, _MAGENTA|BLACK, _MAGENTA|BLUE);
  336.         win1.shadow ();
  337.         win1.title (" Moving Window 1 ");
  338.         win1 << "Here is some text in a moving window.";
  339.  
  340.         win2.open (1, 54, 10, 79, W_DOUSIN, _GREEN|BLACK, _GREEN|WHITE);
  341.         win2.shadow ();
  342.         win2.title (" Moving Window 2 ");
  343.         win2 << "Here is some text in the second moving window.";
  344.         }
  345.     else 
  346.         {
  347.         win1.close ();
  348.         win2.close ();
  349.         }
  350. }
  351.  
  352. // Function to move the random windows every second
  353. // This function is called by the clock function with the current time
  354. void move_windows (struct time t)
  355. {
  356.     static int x = 1, y = 1, sec_hold = 0;
  357.  
  358.     if (!win1.is_open())
  359.         return;
  360.  
  361.     if (sec_hold != t.ti_sec)       // only move once a second
  362.         {
  363.         sec_hold = t.ti_sec;
  364.         x += 6;
  365.         y += 2;
  366.         if ( x > 60 || y > 18)
  367.             {
  368.             x = 0;
  369.             y = 0;
  370.             }
  371.         win1.move (y, x);
  372.  
  373.         // randomly move the second window
  374.         win2.move (random(Win_Max_y () - 11), random(54));
  375.         }
  376. }
  377.  
  378. //***********************Scroll Demo**********************************
  379. void scroll_demo ()
  380. {
  381.     // Windows will open or close with each call
  382.     if (!Scroll.is_open()) 
  383.         {
  384.         int bkground = _CYAN;
  385.         if (VGA)
  386.             bkground = _LCYAN;
  387.  
  388.         Scroll.open (2, 56, 8, 78, W_DOUSIN, bkground|BLACK, bkground|BLUE);
  389.         Scroll.shadow ();
  390.         Scroll.title (" Slow Scroll ");
  391.  
  392.         if (VGA)
  393.             bkground = _YELLOW;
  394.         else
  395.             bkground = _BLUE;
  396.  
  397.         Scroll2.open (11, 56, 16, 78, W_DOUSIN, bkground|RED, bkground|BLACK);
  398.         Scroll2.shadow ();
  399.         Scroll2.title (" Fast Scroll ");
  400.         }
  401.     else 
  402.         {
  403.         Scroll.close ();
  404.         Scroll2.close ();
  405.         }
  406. }
  407.  
  408. void random_message (WinObj &w)
  409. /*
  410.  * All the print messages here accomplish the same results,
  411.  * a cr/lf followed by some text.
  412.  */
  413. {
  414.     switch (random (6))
  415.         {
  416.     case 0:
  417.         w << '\n' << ' ' << w.get_version();
  418.         break;
  419.     case 1:
  420.         w << '\n' << " Lake View Software";
  421.         break;
  422.     case 2:
  423.         w << '\n' << " Borland C++ v2.0";
  424.         break;
  425.     case 3:
  426.         w << "\n Turbo C++ v1.01";
  427.         break;
  428.     case 4:
  429.         w.printf ("\n Support Shareware");
  430.         break;
  431.     default:
  432.         w.puts ("\n Some Scrolling Text");
  433.         break;
  434.     }
  435. }
  436.  
  437. void scroll_window ()
  438. {
  439.     if (!Scroll.is_open())
  440.         return;
  441.  
  442.        static clock_t clock1 = 0, clock2 = 0;
  443.  
  444.     if ((clock1 + 5) < clock () )
  445.         {
  446.         random_message (Scroll);
  447.         clock1 = clock ();
  448.         }
  449.  
  450.     if ((clock2+1) < clock ())
  451.         {
  452.         random_message (Scroll2);    // Fast scroll
  453.         clock2 = clock ();
  454.         }
  455. }
  456.  
  457. //**********************Random Windows Demo***************************
  458. void random_windows ()
  459. {
  460.     WinObj win1, win2, win3, win4, win5;    // Create some random windows
  461.     rand_open (win1);
  462.     delay (250);         // Pause for effect
  463.     rand_open (win2);
  464.     delay (250);         // Pause for effect
  465.     rand_open (win3);
  466.     delay (250);         // Pause for effect
  467.     rand_open (win4);
  468.     delay (250);         // Pause for effect
  469.     rand_open (win5);
  470.     delay (250);         // Pause for effect
  471.     win1.clr_win ();
  472.     win1 << "Press any key to continue.";
  473.     win1.get_key (0, 10);    // wait 10 seconds for a key
  474. }
  475.  
  476. // Function to open random windows on the screen
  477. void rand_open (WinObj &w)
  478. {
  479.     static cnt = 0;
  480.     int sr, er, sc, ec;
  481.     int color, bcolor, btype;
  482.  
  483.     sr = random (Win_Max_y () - 14);
  484.     sc = random (40);
  485.     er = sr + 10 + random ((Win_Max_y () - 14)-sr);
  486.     ec = sc + 15 + random (63-sc);
  487.  
  488.     int bk_colors = 8;
  489.     if (VGA)
  490.         bk_colors = 16;
  491.  
  492.     color = random (bk_colors) * 16 + random (16);
  493.     bcolor = random (bk_colors) * 16 + random (16);
  494.     btype = random (MAX_BOX_TYPE + 1);
  495.     w.open (sr, sc, er, ec, btype, color, bcolor);
  496.     w.shadow ();
  497.     w.title (" Random Window ");
  498.     w << "This is random window #(" << ++cnt << ")";
  499. }
  500.  
  501. //************************Data Entry Demo********************************
  502.  
  503. void paint_data_screen (WinObj &w)
  504. {
  505.     w.printf (1, 1, "  Last Name:");
  506.     w.printf (2, 1, " First Name:");
  507.     w.printf (4, 1, "    Address:");
  508.     w.printf (6, 1, "City/St/Zip:");
  509.     w.printf (6, 29, ",");
  510.     w.printf (8, 1, "      Phone:");
  511.     w.printf (10, 1, " Start Date:");
  512.     w.printf (12, 1, "       Age:");
  513.     w.printf (14, 1, "    Salary:");
  514. }
  515.  
  516. int read_data (WinObj &w)        // read data for data_entry or print for print_data
  517. {
  518.     // Declare data variables.
  519.     static char lastname[16] = "", firstname[16] = "";
  520.     static char add1[31] = "", add2[31] = "";
  521.     static char city[16] = "", state[3] = "", zip[11] = "";
  522.     static char phone[15] = "";
  523.     static char start[9] = "";
  524.     static double salary = 0;
  525.     static long age = 0;
  526.  
  527.     str_setsz (lastname, 15);    // We won't use a picture for these
  528.     str_setsz (firstname, 15);   // variables, so we must give the initial
  529.     str_setsz (add1, 30);        // value some size.
  530.     str_setsz (add2, 30);
  531.     str_setsz (city, 15);
  532.     str_setsz (state, 2);
  533.  
  534.     w.get (1, 14, lastname, 'F');  // force first character of these fields
  535.     w.get (2, 14, firstname, 'F'); // to be upper case with a 'F'orce style.
  536.     w.get (4, 14, add1, 'F');
  537.     w.get (5, 14, add2, 'F');
  538.     w.get (6, 14, city, 'F');
  539.  
  540.     w.get (6, 31, state, 'U');        // force state to be uppercase
  541.     w.get (6, 35, zip, "99999-9999");  // use a picture for a zip code
  542.  
  543.     w.get (8, 14, phone, 'P');     // get a phone style
  544.     w.get (10, 14, start, 'D');    // get a date style
  545.     w.get (12, 14, age, 3);        // Limit age to 3 places
  546.     w.valid (v_age);            // check age to be over 15
  547.  
  548.     w.get (14, 14, salary, 9);     // limit salary to hundred thousands
  549.     w.valid (v_salary);         // check to be sure salary is over $10,000
  550.  
  551.     return (w.read ());           // read the gets
  552. }
  553.  
  554. void print_data ()
  555. {
  556.     if (!Win_Get_YN ("Printer ready"))
  557.         return;
  558.     
  559.     Win_Prn p;
  560.     if (p.open () != W_OK)
  561.         {
  562.         Win_Error ("Can't open printer port!");
  563.         return;
  564.         }
  565.  
  566.     paint_data_screen (p);        // Paint the screen in memory
  567.     read_data (p);                // Paint the gets in memory
  568.  
  569.     //
  570.     // Now lets change some of the print attributes.
  571.     // These normaly would could be set before each printf or puts...
  572.     // but since I used the same routines to print the screen and the
  573.     // page this is being done later.
  574.     //
  575.     p.set_pageattr (P_NORMAL);    // Set attributes for the entire page
  576.     p.set_attr (P_UNDERLINE, 1, 14, 15);    // Underline the last name
  577.  
  578.     p.print_page ();            // Print physical page
  579.  
  580.     p.close ();                    // could let close with distructor
  581. }
  582.  
  583. void data_entry()
  584. {
  585.     WinObj  w(40,65);      // Create the main entry window
  586.     w.open (3, 14, 12, 62, W_DOUBLE, _BLUE|WHITE, _BLUE|YELLOW);
  587.     w.shadow ();
  588.     w.title(" Data Entry ");
  589.  
  590.     paint_data_screen (w);        // Paint the screen
  591.     if (read_data (w) != ESC)                // Get the data
  592.         if (Win_Get_YN ("Do you wish to print the data"))
  593.             print_data ();
  594. }
  595.  
  596. int v_salary(void *num)             // Valid function for salary
  597. {
  598.     if (* (double *)num >= 10000)     // Must first conver num to a double type
  599.         return 1;                   // pointer.  if >= 10,000 return true.
  600.  
  601.     Win_Error (" Salary must be > 10,000! ");
  602.     return 0;                       // return false.
  603. }
  604.  
  605. int v_age(void *num)             // Valid function for age
  606. {
  607.     if (* (int *)num > 15)             // Must first conver age to a integer type
  608.         return 1;                   // pointer.  if > 15 return true.
  609.  
  610.     Win_Error (" Age must be > 15 ");
  611.     return 0;                       // return false.
  612. }
  613.  
  614. //*************************Paradox Entry*********************************
  615. #ifdef __TURBOC__
  616. char *Text[] = {
  617.     "Entering text in a Paradox Table is one of the many features of LVS",
  618.     "Windows.  It allows you to enter directly into the Paradox record",
  619.     "buffer, with no temporary variables.",
  620.     "",
  621.     "I'd like to show you how to enter text in a Paradox Table using LVS",
  622.     "Windows, but I would have to write this in the large model and I've",
  623.     "only supplied the small model here.  So here's what the code would",
  624.     "look like.",
  625.     "",
  626.     "To view the code use the Up and Down arrows keys.",
  627.     "                   Esc to exit",
  628.     "",
  629.     "",
  630.     "#include <pxengine.h>",
  631.     "#include <winobj.hpp>",
  632.     "",
  633.     "main ()  {",
  634.     "   TABLEHANDLE TblHandle;",
  635.     "   RECORDHANDLE RecHandle;",
  636.     "",
  637.     "   PXInit ();                              // Init the PX engine",
  638.     "   PXTblOpen (\"SALES\", &TblHandle, 0, 0);  // Open the table",
  639.     "   PXRecBufOpen (TblHandle, &RecHandle);   // Open a record buffer",
  640.     "   PXRecFirst (TblHandle);                 // Point to the first record",
  641.     "   PXRecGet (TblHandle, RecHandle);        // Read the record.",
  642.     "",
  643.     "   WinObj w;                               // my window object",
  644.     "   w.open (0, 0, 24, 79);                  // Open the window",
  645.     "   w.PXrecord (TblHandle, RecHandle);      // give winobj the PX info",
  646.     "   w.PXget (1, 1, 1, 'F');                 // Get the first field, style 'F'",
  647.     "   w.PXget (3, 1, 2, 'F');",
  648.     "   w.PXget (5, 1, 11, 'P');                // Get the 11 field, style Phone",
  649.     "   w.PXget (7, 1, 17, 10, 2);",
  650.     "   w.PXget (9, 1, 18, 3, 0);",
  651.     "   w.PXread ();                            // Read the user input",
  652.     "   PXRecUpdate (TblHandle, RecHandle);     // update the PX record",
  653.     "   PXExit ();                              // Stop the PX engine",
  654.     "}",
  655.     "",
  656.     "",
  657.     "Paradox in a Trademark of Borland",
  658.     0 };
  659. #endif
  660.  
  661. void paradox_entry ()
  662. {
  663. #ifdef __TURBOC__
  664.     WinObj w (43, 78);
  665.  
  666.     w.open (1, 0, 23, 79, W_SINGLE, _BLUE|WHITE, _BLUE|CYAN);
  667.     w.title (" Paradox Entry ");
  668.     int i = -1;
  669.     while (Text [++i])
  670.         w.puts (i+1, 2, Text [i]);
  671.  
  672.     w.gotoxy ();
  673.  
  674.     int key = 0;
  675.     do {
  676.         key = w.get_key (0, 60);      // wait 1 minute for a key press
  677.  
  678.         switch (key)
  679.             {
  680.             case UP:
  681.                 w.gotoxy (w.wherey () - 1, w.wherex ());
  682.                 break;
  683.             case DOWN:
  684.                 if (w.wherey () < w.max_y ())
  685.                     w.gotoxy (w.wherey () + 1, w.wherex ());
  686.                 break;
  687.             case LEFT:
  688.                 w.gotoxy (w.wherey (), w.wherex () - 1);
  689.                 break;
  690.             case RIGHT:
  691.                 w.gotoxy (w.wherey (), w.wherex () + 1);
  692.                 break;
  693.             }
  694.  
  695.         } while (key && (key != ESC));
  696. #endif
  697. }
  698.  
  699. //**************************Clock function*******************************
  700.  
  701. void show_time ()        // Show time in upper left corner of screen
  702. {
  703.     static struct time t;
  704.     static WinObj clock_win;    // create a static window object
  705.     static unsigned char hold;
  706.  
  707.     WinObj *w_hold = Win_whos_active ();
  708.  
  709.     if (!clock_win.is_open())       // open small clock window once
  710.         {
  711.         int color = _LGREY|BLUE;
  712.         if (VGA)
  713.             color = _WHITE|BLUE;
  714.             
  715.         clock_win.open (0, 0, 0, 79, W_NOBORDER, color);
  716.         clock_win.center (0, "Lake View Software");
  717.         }
  718.  
  719.     /*
  720.      * First show the clock
  721.      */
  722.     gettime (&t);
  723.     if (hold != t.ti_sec) {
  724.         hold = t.ti_sec;
  725.         clock_win.printf (0, 1, "%02d:%02d:%02d", t.ti_hour, t.ti_min, t.ti_sec);
  726.         #ifndef DOS386
  727.         clock_win.printf (0, 73, "%6ld", (long )coreleft ());  // show free mem
  728.         #endif
  729.     }
  730.  
  731.     /*
  732.      * Move the random windows
  733.      */
  734.     move_windows(t);
  735.  
  736.     /*
  737.      * scroll text in window
  738.      */
  739.     scroll_window ();
  740.  
  741.     /*
  742.      * Restore the currently active window
  743.      */
  744.     w_hold->set_active ();
  745. }
  746.  
  747. //**********************Help Function***********************************
  748. void help()
  749. {
  750.     static int is_active=0;
  751.     int old_x, old_y;
  752.     if (is_active)
  753.         return;
  754.     is_active++;
  755.     Win_getxy (&old_y, &old_x);       // Save current cursor position
  756.  
  757.     WinObj help;
  758.  
  759.     int bkground = _LGREY;
  760.     if (VGA)
  761.         bkground = _LBLUE;
  762.  
  763.     help.open (2, 11, 22, 67, W_SINGLE, bkground|BLACK, bkground|WHITE);
  764.     help.shadow ();
  765.     help.title (" Help Window ");
  766.     help.center (1, "Data Entry Keys");
  767.     help.gotoxy (3, 1) << "/ arrows        Move cursor to next/prev field.";
  768.     help.printf (4, 1, "%c/%c arrows        Move cursor to next/prev column.",26,27);
  769.     help.printf (5, 1, "Ctrl_%c/%c arrows   Pan window right/left one column.",26,27);
  770.     help.printf (6, 1, "Ctrl_end/home     Pan window down/up one row.");
  771.     help.printf (7, 1, "PgDn              Exit read mode.");
  772.     help.printf (8, 1, "Esc               Quit read mode.");
  773.     int hold_attr = help.set_attr (bkground|WHITE);
  774.     help.center (10, "Non Picture Gets Only");
  775.     help.set_attr (hold_attr);
  776.     help.printf (11, 1, "Insert            Toggle insert/overtype mode.");
  777.     help.printf (12, 1, "Delete            Delete character under cursor.");
  778.     help.printf (13, 1, "Backspace         Delete previous character.");
  779.     hold_attr = help.set_attr (bkground|RED);
  780.     help.center (17, "Copyright (c) 1991, Lake View Software");
  781.     help.set_attr (hold_attr);
  782.     help.center (18, "Press any key to exit.");
  783.     Win_getkey (15);                // wait 15 seconds for a key 
  784.  
  785.     Win_gotoxy (old_y, old_x);        // Restore cursor position
  786.     is_active = 0;                  // turn off active flag
  787. }
  788.  
  789.  
  790. //*****************************Logo*****************************************
  791.  
  792. void function_key_mouse_routine (int y, int x)
  793. /*
  794.  * Check mouse clicks for function keys
  795.  * This routine will be attached to the footer
  796.  * window.
  797.  */
  798. {
  799.     if (y != 0)
  800.         return;
  801.  
  802.     if (x >=21 && x <= 27)
  803.         Win_keystuf (F1);
  804.  
  805.     if (x >= 30 && x <= 40)
  806.         Win_keystuf (F5);
  807.  
  808.     if (x >= 43 && x <= 56)
  809.         Win_keystuf (F10);
  810. }
  811.  
  812. void logo ()
  813. {
  814.     int max_y = Win_Max_y ();           // Get the max y coordinate
  815.  
  816.     if (Use_VGA)
  817.         {
  818.         if (VGA_videotype () == V_VGA)
  819.             {
  820.             /*
  821.              * Turn blink off to allow highlight backgrounds
  822.              */
  823.             VGA_setblink (W_OFF);
  824.  
  825.             /*
  826.              * load special fonts
  827.              */
  828.  
  829.             VGA_fontload ();
  830.  
  831.             VGA++;      // set vga flag
  832.             }
  833.         }
  834.  
  835.     /*
  836.      * Open a window to cover the screen
  837.      */
  838.     static WinObj Main;
  839.     int bkground = _BLACK;
  840.     if (VGA)
  841.         bkground = _DGREY;
  842.     Main.open (0, 0, max_y, 79, W_NOBORDER, bkground|LGREY);
  843.  
  844.     for (int x = 0; x < max_y * 2 + max_y / 5; x++)
  845.         Main.printf ("- LVS Windows -- Lake View Software -");
  846.     
  847.  
  848.     /*
  849.      * Display the footer
  850.      */
  851.     static WinObj Footer;
  852.     int color = _LGREY|BLACK;
  853.     if (VGA)
  854.         color = _WHITE|BLACK;
  855.  
  856.     Footer.open (max_y, 0, max_y, 79, W_NOBORDER, color);
  857.     Footer.puts (0, 21, "F1=Help, F5=Calendar, F10=Calculator");
  858.     Footer.set_mouseroutine (function_key_mouse_routine);
  859.  
  860.     /*
  861.      * Display the logo
  862.      */
  863.     static WinObj logo;
  864.     color = _BLACK;
  865.     if (VGA)
  866.         color = _DGREY;
  867.  
  868.     logo.open (max_y - 5, 19, max_y - 2, 59, W_DOUSIN, 
  869.                color|WHITE, color|YELLOW);
  870.     logo.shadow ();
  871.  
  872.     logo.title (logo.get_version ());
  873.     logo.center (0, "The C++ window class system");
  874.     logo.center (1,"Copyright (c) 1991");
  875.  
  876.     show_time ();       // displays the title bar and time for the first time
  877. }
  878.